<!-- 订单确认-结算 -->
<template>
  <div class="mall_page">
    <ConfirmOrder />
  </div>
</template>

<script>
import { mapState } from 'vuex';
import { getToken } from '@/lib/auth';
import { loginOidc } from '@/lib/oidc_fun';
import ConfirmOrder from '@/components/Settlement/confirmOrder';
export default {
  name: 'Settlement',
  components: {
    ConfirmOrder
  },
  data() {
    return {
      loading: false
    };
  },
  computed: {
    ...mapState({
      vxCurrentUserType: state => state.user.currentUserType,
      tokenInfo: state => state.user.token || getToken()
    }),
    vxRegisterId () {
      return this.vxCurrentUserType ? this.vxCurrentUserType.registerId : '';
    },
    tenantId() {
      const _ids = this.$route.params.id.split('_');
      return _ids[1] && _ids[1] !== 'plat' ? _ids[1] : '';
    }
  },
  created() {
    this.checkIsLogin();
  },
  methods: {
    checkIsLogin() {
      if (!this.tokenInfo) {
        // 未找到token,需要登录
        this.goLogin();
        return false;
      }
    },
    goLogin() {
      const tenantId = this.tenantId + '___' + ENVIR;
      let href = window.location.href;
      href =
        href.indexOf('#') > -1
          ? href.indexOf('?') > -1
            ? href + '&'
            : href + '?'
          : href + '#/?';
      href = href
        .replace(/loginRandom=[0-9]+|loginRandom=/g, '')
        .replace(/&&+/g, '&')
        .replace('?&', '?');
      href = href + 'loginRandom=' + new Date().getTime();
      // 跳转登录
      loginOidc({
        state: window.btoa(href),
        acr_values: tenantId ? window.btoa(tenantId) : ''
      });
    }
  }
};
</script>

<style scoped>

</style>
